def getAndSetItem():
    L = ['大海', 1, 1.2, [1.22, '小海']]
    print(L)
    print(L[1])
    print(L[-1])  # 反向取
    # print(L[10]) # IndexError: list index out of range
    L[0] = '红海'
    print(L)
    print(len(L))
    print(3 in L)
    print(3 not in L)


# getAndSetItem()


def splitList():
    nums = [1, 2, 3, 5, 4, 6, 9, 7, 7, 8]
    print(nums[0:11:2])  # 越界不会报错
    print(nums[11:3:-2])  # 越界不会报错


# splitList()

def crud():
    nums = [1, 2, 3, 5, 4, 6, 9, 7, 7, 8]
    print('nums: ', nums)
    print('len: ', len(nums))
    print('count(7): ', nums.count(7))
    nums.insert(2, 10)
    print("insert(2, 10):", nums)
    nums.extend([11, 13])
    print('extend: ', nums)
    nums.append(16)
    print('append: ', nums)
    del nums[0]
    print('del: ', nums)
    nums.pop()
    print('pop: ', nums)
    nums.pop(0)
    print('pop(0): ', nums)
    nums.clear()
    print('clear: ', nums)


# crud()


def sort():
    nums = [1, 2, 3, 5, 4, 6, 9, 7, 7, 8]
    print('nums: ', nums)
    nums.reverse()
    print('reverse: ', nums)
    nums.sort()
    print('sort: ', nums)
    nums.sort(reverse=True)
    print('sort(reverse=False): ', nums)


sort()
